package com.ytjj.qmyx.mall.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
public enum WxComplaintsStatusEnums {
    CREATE_COMPLAINT("CREATE_COMPLAINT","用户提交投诉"),
    CONTINUE_COMPLAINT("CONTINUE_COMPLAINT","用户继续投诉"),
    USER_RESPONSE("USER_RESPONSE","用户新留言"),
    RESPONSE_BY_PLATFORM("RESPONSE_BY_PLATFORM","平台新留言"),
    SELLER_REFUND("SELLER_REFUND","商户发起全额退款"),
    MERCHANT_RESPONSE("MERCHANT_RESPONSE","商户新回复"),
    MERCHANT_CONFIRM_COMPLETE("MERCHANT_CONFIRM_COMPLETE","商户反馈处理完成"),
    MERCHANT_APPROVE_REFUND("MERCHANT_APPROVE_REFUND","商户同意退款"),
    MERCHANT_REJECT_REFUND("MERCHANT_REJECT_REFUND","商户驳回退款"),
    REFUND_SUCCESS("REFUND_SUCCESS","退款到账");

    private String code;

    private String msg;


    WxComplaintsStatusEnums(String code, String msg){
        this.code = code;
        this.msg = msg;
    }


    public static String getMsg(String code) {
        WxComplaintsStatusEnums[] values = WxComplaintsStatusEnums.values();
        for(WxComplaintsStatusEnums enums : values){
            if(enums.getCode().equals(code)){
                return enums.getMsg();
            }
        }
        return null;
    }

    /**
     * 是否可以自动回复
     * @param code
     * @return
     */
    public static boolean isAutoReply(String code){
        Map<String,String> map = new HashMap<>();
        //用户提交投诉
        map.put(WxComplaintsStatusEnums.CREATE_COMPLAINT.getCode(),CREATE_COMPLAINT.getMsg());
        //用户继续投诉
        map.put(WxComplaintsStatusEnums.CONTINUE_COMPLAINT.getCode(),CONTINUE_COMPLAINT.getMsg());
        //用户新留言
        map.put(WxComplaintsStatusEnums.USER_RESPONSE.getCode(),USER_RESPONSE.getMsg());

        if(null != map.get(code) && !"".equals(map.get(code))){
            return true;
        }
        return false;
    }
}
